class Main extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            time:0,
            data:{
                one:'',
                two:'',
                three:'',
                four:'',
            },
        };
    }









    componentDidMount() {

      let myphone =localStorage.getItem('phone')
        if(myphone!=null){
            myphone= maskPhoneNumber(myphone)
            this.setState({ myphone })
        }
        if (Constant.SWITCH_VCONSOLE) {
            new VConsole();
        }
        
        当前碎片(res=>{
            if(res.data){
                this.setState({data:res.data})
            }
        })

        //  console.log(liststr?'1':'2','liststr');
        // let list = JSON.parse(localStorage.getItem('orderlist')) || []
        // console.log(list, 'list');

        // this.setState({ list }, () => {
        //     this.getamount()
        // })
        // this.getdata()

    }
    go(e){
        let {data} = this.state,cango=!0
        switch (e) {
            case 1:{ if(data.one==1){  cango=!1  }  break; }
            case 2:{ if(data.two==1){  cango=!1  }  break; }
            case 3:{ if(data.three==1){  cango=!1  }  break; }
            case 4:{ if(data.four==1){  cango=!1 }  break; }
           
            default:
                break;
        }
        if(cango){
            window.location.href='./detail.html?type='+e
        }
    }

  

   

    quit(){
        let{time} = this.state
        if(time==5){
            localStorage.removeItem('phone')
            localStorage.removeItem('userid')
            localStorage.removeItem('token')
            window.location.href='./index.html'
        }else{
            console.log(time,'time');
            this.setState({time:time+1})
        }
    }

  

    selectchange(e) {
        let { value } = e.target
        this.setState({ sizeid: value })
    }

    selectchange1(e) {
        let { value } = e.target, { amount, allprice } = this.state;
        if (value == 0) {
            amount = 610
        } if (value == -1) {
            amount = 300
        } if (value == 1) {
            amount = 835
        }
        this.setState({ cpid: value, amount })
    }


    render() {
        let { myphone,data, sizeid, cphtml, cpid } = this.state;
        //  console.log(sizehtml, 'sizehtml');
        return (
            <div id="app">
                  <div  className="myinfo">您好,{myphone}</div>
                <img className="bg" src="./src/main_bg.png" alt="" />
                <img onClick={()=>{
                    window.location.href='./hdsm.html'
                }} className="hdsm" src="./src/hdsm.png" alt="" />
                <div className="part">
                    <div>
                        <img onClick={this.go.bind(this,'1')} src={`./src/moon1${data.one == 1 ? '_c' : ''}.png`} alt="" />
                        <img onClick={this.go.bind(this,'2')}src={`./src/moon2${data.two == 1 ? '_c' : ''}.png`} alt="" />
                    </div>
                    <div>
                        <img onClick={this.go.bind(this,'3')}src={`./src/moon3${data.three == 1 ? '_c' : ''}.png`} alt="" />
                        <img onClick={this.go.bind(this,'4')}src={`./src/moon4${data.four == 1 ? '_c' : ''}.png`} alt="" />
                    </div>

                </div>
                <div className="btns">
                    <img onClick={()=>{
                        window.location.href = './lottery.html'
                    }}  src="./src/main_btn1.png" alt="" />
                    <img onClick={()=>{
                        window.location.href = './mygift.html'
                    }}  src="./src/main_btn2.png" alt="" />
                </div>
                {/* <img src="./src/main_2.png" alt="" />
                <img src="./src/main_3.png" alt="" /> */}

            </div>
        )
    }
}

ReactDOM.render(
    <div>
        {/* <TopLine /> */}
        <div id='body'>
            {/* <Tabbar index='1' /> */}
            <Main />
        </div>
    </div>
    // <Barrage />
    , $('.container')[0]
)